﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="Scripts/jquery-3.3.1.min.js"></script>
    <script src="Scripts/md5.js"></script>
</head>
<body>
    <input type="button" value="登录" id="login" />
    <script type="text/javascript">
        $(function () {
            var org = {
                "grant_type": 'password',
                "username": '丁林玲',
                "client_id": '138B0798-8D43-4588-B291-DB8545865C8A',
                "jxsh": '000000',
                "czydm": 600116
            }
            debugger
            var formData = new FormData();
            formData.append('grant_type', 'password');
            formData.append('username', '丁林玲');
            formData.append('client_id', '138B0798-8D43-4588-B291-DB8545865C8A');
            $("#login").click(function () {
                $.ajax({
                    url: 'https://localhost:44351/api/connect/token',
                    //url:'https://devapi.chinacloudsites.cn/api/connect/token',
                    type: 'POST',                   
                    data: 'grant_type=password&client_id=138B0798-8D43-4588-B291-DB8545865C8A', 
                    success: function (res) {
                        self.data = res.data.slice(0, 3)
                        self.opencode = res.data[0].opencode.split(',')
                    }, error: function (res) {
                        console.log(res)
                    }
                })


                //$.ajax({
                //    url: 'http://112.124.23.230:8010/API/LoginAPIHandler.ashx?action=validLogin_JXS',
                //    type: 'POST',
                //    headers: {
                //        'Access-Control-Allow-Orign': '*',
                //        'Access-Control-Allow-Methods':'POST,GET',
                //        'Content-Type': 'application/json;charset=utf8',
                //        "appId": appId,
                //        "timestamp":timestamp,
                //        "nonce": nonce,
                //        "sign": sign
                //    },
                //    data: JSON.stringify(org),
                //    //data: org,
                //    //dataType: "json",
                //    dataType: 'JSONP',
                //    success: function (res) {
                //        self.data = res.data.slice(0, 3)
                //        self.opencode = res.data[0].opencode.split(',')
                //    }, error: function (res) {
                //        console.log(res)
                //    }
                //})

                //$.ajax({

                //    //url: 'https://localhost:44351/api/menu/GetMenuList',
                //    url: 'http://localhost:51163/api/menu/GetMenuList',
                //    type: 'post',
                //    //dataType: 'JSONP',
                //    //jsonp: "callback",
                //    //jsonpCallback: "success_jsonpCallback",
                //    success: function (res) {
                //        self.data = res.data.slice(0, 3)
                //        self.opencode = res.data[0].opencode.split(',')
                //    }
                //})

            });


            function dateFormat(time) {
                var date = new Date(time);
                var year = date.getFullYear();
                /* 在日期格式中，月份是从0开始的，因此要加0
                 * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
                 * */
                var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
                var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
                var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
                var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
                // 拼接
                //return year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;
                return year + month + day + hours + minutes + seconds;
            }
        });

    </script>
</body>
</html>